package site.xuqing.autohelperengine.util;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;

public class ScreenUtil {
    private static ScreenUtil screenUtil;
    public int screenSizeWidth;
    public int screenSizeHeight;
    private ScreenUtil(){}
    public static ScreenUtil getInstance(){
        if (screenUtil==null){
            screenUtil=new ScreenUtil();
        }
        return screenUtil;
    }
    public void init(Context context){
        initScreenInfo(context.getApplicationContext());
    }

    private void initScreenInfo(Context context) {
        WindowManager mWm = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);
        if (mWm != null) {
            DisplayMetrics dm = new DisplayMetrics();
            Display d = mWm.getDefaultDisplay();
            if (d != null) {
                d.getMetrics(dm);
                screenSizeWidth = dm.widthPixels;
                screenSizeHeight = dm.heightPixels;
            }
        }
    }
}
